package com.situ.gym.controller;

import com.situ.gym.pojo.vo.ChartCountVO;
import com.situ.gym.pojo.vo.DayCountVO;
import com.situ.gym.service.ICoachService;
import com.situ.gym.service.ICourseService;
import com.situ.gym.service.IReserveService;
import com.situ.gym.service.IUserService;
import com.situ.gym.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/chart")
public class ChartController {
    @Autowired
    private ICoachService coachService;
    @Autowired
    private IUserService userService;
    @Autowired
    private IReserveService reserveService;
    @Autowired
    private ICourseService courseService;

    @GetMapping("/selectCoachCount")
    public Result<List<ChartCountVO>> selectCoachCount() {
        List<ChartCountVO> list = coachService.selectCoachCount();
        return Result.ok(list);
    }

    @GetMapping("/selectUserTotal")
    public Result<Long> selectUserTotal() {
        long count = userService.count();
        return Result.ok(count);
    }

    @GetMapping("/selectCoachTotal")
    public Result<Long> selectCoachTotal() {
        long count = coachService.count();
        return Result.ok(count);
    }


    @GetMapping("/selectReserveTotal")
    public Result<Long> selectReserveTotal() {
        long count = reserveService.count();
        return Result.ok(count);
    }

    @GetMapping("/selectCourseTotal")
    public Result<Long> selectCourseTotal() {
        long count = courseService.count();
        return Result.ok(count);
    }


    @GetMapping("/selectHotCourse")
    public Result<List<ChartCountVO>> selectHotCourse() {
        List<ChartCountVO> list = courseService.selectHotCourse();
        return Result.ok(list);
    }


    @GetMapping("/selectUserCount")
    public Result<List<DayCountVO>> selectUserCount(Date date) {
        List<DayCountVO> list = userService.selectUserCount(date);
        return Result.ok(list);
    }

    @GetMapping("/selectReserveCount")
    public Result<List<DayCountVO>> selectReserveCount(Date date) {
        List<DayCountVO> list = reserveService.selectReserveCount(date);
        return Result.ok(list);
    }
}
